//
//  UIImageView+LCExtension.m
//  LCPackage
//
//  Created by 马军凯 on 2021/6/22.
//  Copyright © 2021 龙采科技集团. All rights reserved.
//

#import "UIImageView+LCExtension.h"
#import "UIImageView+WebCache.h"
#import "RBURLConfig.h"
@implementation UIImageView (LCExtension)

- (void)LC_setImageWithURL:(NSString *)url {
    NSString *urlString = url;
    if (![urlString hasPrefix:@"http"]) {
        urlString = [NSString stringWithFormat:@"%@/%@", [[RBURLConfig shareInstance] commonServiceBaseUrl], url];
    }
    
    [self sd_setImageWithURL:[NSURL URLWithString:urlString]];
}

- (void)LC_setImageWithURL:(NSString *)url placeholder:(NSString *)placeholder {
    NSString *urlString = url;
    if (![urlString hasPrefix:@"http"]) {
        urlString = [NSString stringWithFormat:@"%@/%@", [[RBURLConfig shareInstance] commonServiceBaseUrl], url];
    }
    
    [self sd_setImageWithURL:[NSURL URLWithString:urlString] placeholderImage:[UIImage imageNamed:placeholder]];
}

- (void)LC_setImageWithURL:(NSString *)url placeholder:(NSString *)placeholder optionInfo:(SDWebImageOptions)options {
    NSString *urlString = url;
    if (![urlString hasPrefix:@"http"]) {
        urlString = [NSString stringWithFormat:@"%@/%@", [[RBURLConfig shareInstance] commonServiceBaseUrl], url];
    }
    [self sd_setImageWithURL:[NSURL URLWithString:urlString] placeholderImage:[UIImage imageNamed:placeholder] options:options];
}

+ (void)LC_ImageClearCache {
    
    [[SDImageCache sharedImageCache] clearDiskOnCompletion:^{
        
    }];
    [[SDImageCache sharedImageCache] clearMemory];
}
@end
